/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package store;

import controller.layerController;
import java.util.ArrayList;

/**
 *
 * @author JorgeLuis
 */
public class layersStore {
    private ArrayList<layerController> layers = new ArrayList<layerController>();
    private layerController selectLayer = null;
    public layersStore() {
    }
   
    public void selectLayer(int index){
        if(index > layers.size()){
            System.out.println("No se encontro la capa");
        }
         this.selectLayer = layers.get(index);
        
    }
    
    public int findLayerIndex(int id){
        
        for (int i = 0; i < this.layers.size(); i++) {
            System.out.println("Capa : "+ this.layers.get(i).getId());
            if(this.layers.get(i).getId() == id){
                return i;
            }
        }
        return -1;
    }
    
    public layerController getSelectLayer(){
        return this.selectLayer;
    }
    
   public void newLayer(int id, int parentId){
       layers.add(new layerController(id, parentId));
       
       if(layers.size() == 1){
           this.selectLayer(0);
       }
   }

    public void deleteLayer(int id) {
        for (int i = 0; i < layers.size(); i++) {
            if(layers.get(i).getId() == id){
                layers.remove(i);
                i = layers.size();
            }
        }
    }
    
}
